<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AngelScript: dictionary object</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   
   </div>
   
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('doc_addon_dict.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">dictionary object </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p><b>Path:</b> /sdk/add_on/scriptdictionary/</p>
<p>The dictionary object maps string values to values or objects of other types.</p>
<p>Register with <code>RegisterScriptDictionary(asIScriptEngine*)</code>.</p>
<h2><a class="anchor" id="doc_addon_dict_1"></a>
Public C++ interface</h2>
<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CScriptDictionary
{
<span class="keyword">public</span>:
  <span class="comment">// Memory management</span>
  CScriptDictionary(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine);
  <span class="keywordtype">void</span> AddRef() <span class="keyword">const</span>;
  <span class="keywordtype">void</span> Release() <span class="keyword">const</span>;

  <span class="comment">// Perform a shallow copy of the other dictionary</span>
  CScriptDictionary &amp;operator=(<span class="keyword">const</span> CScriptDictionary &amp;other);

  <span class="comment">// Sets/Gets a variable type value for a key</span>
  <span class="keywordtype">void</span> Set(<span class="keyword">const</span> std::string &amp;key, <span class="keywordtype">void</span> *value, <span class="keywordtype">int</span> typeId);
  <span class="keywordtype">bool</span> Get(<span class="keyword">const</span> std::string &amp;key, <span class="keywordtype">void</span> *value, <span class="keywordtype">int</span> typeId) <span class="keyword">const</span>;

  <span class="comment">// Sets/Gets an integer number value for a key</span>
  <span class="keywordtype">void</span> Set(<span class="keyword">const</span> std::string &amp;key, <a class="code" href="angelscript_8h.html#aa8044b56ee56e2350b06f1e7207b43df" title="64 bit integer">asINT64</a> &amp;value);
  <span class="keywordtype">bool</span> Get(<span class="keyword">const</span> std::string &amp;key, <a class="code" href="angelscript_8h.html#aa8044b56ee56e2350b06f1e7207b43df" title="64 bit integer">asINT64</a> &amp;value) <span class="keyword">const</span>;

  <span class="comment">// Sets/Gets a real number value for a key</span>
  <span class="keywordtype">void</span> Set(<span class="keyword">const</span> std::string &amp;key, <span class="keywordtype">double</span> &amp;value);
  <span class="keywordtype">bool</span> Get(<span class="keyword">const</span> std::string &amp;key, <span class="keywordtype">double</span> &amp;value) <span class="keyword">const</span>;

  <span class="comment">// Returns true if the key is set</span>
  <span class="keywordtype">bool</span> Exists(<span class="keyword">const</span> std::string &amp;key) <span class="keyword">const</span>;
  
  <span class="comment">// Deletes the key</span>
  <span class="keywordtype">void</span> Delete(<span class="keyword">const</span> std::string &amp;key);
  
  <span class="comment">// Deletes all keys</span>
  <span class="keywordtype">void</span> DeleteAll();
};
</pre></div><h2><a class="anchor" id="doc_addon_dict_2"></a>
Public script interface</h2>
<pre>
  class dictionary
  {
    dictionary &amp;opAssign(const dictionary &amp;in other);</pre><pre>    void set(const string &amp;in key, ? &amp;in value);
    bool get(const string &amp;in value, ? &amp;out value) const;</pre><pre>    void set(const string &amp;in key, int64 &amp;in value);
    bool get(const string &amp;in key, int64 &amp;out value) const;</pre><pre>    void set(const string &amp;in key, double &amp;in value);
    bool get(const string &amp;in key, double &amp;out value) const;</pre><pre>    bool exists(const string &amp;in key) const;
    void delete(const string &amp;in key);
    void deleteAll();
  }
</pre><h2><a class="anchor" id="doc_addon_dict_3"></a>
Script example</h2>
<pre>
  dictionary dict;
  obj object;
  obj @handle;</pre><pre>  dict.set("one", 1);
  dict.set("object", object);
  dict.set("handle", @handle);</pre><pre>  if( dict.exists("one") )
  {
    bool found = dict.get("handle", @handle);
    if( found )
    {
      dict.delete("object");
    }
  }</pre><pre>  dict.deleteAll();
</pre> </div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>

    <li class="footer">Generated on Sun Jan 29 2012 15:41:03 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
